<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>pwn-note(form brokenpoems) | FOR DREAM</title><meta name="author" content="wjuwju"><meta name="copyright" content="wjuwju"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="pwn-notegcc 编译的指令 NX:-z execstack &#x2F; -z noexecstack (关闭 &#x2F; 开启) Canary:-fno-stack-protector &#x2F;-fstack-protector &#x2F; -fstack-protector-all (关闭 &#x2F; 开启 &#x2F; 全开启) PIE:-no-pie &#x2F; -pi">
<meta property="og:type" content="article">
<meta property="og:title" content="pwn-note(form brokenpoems)">
<meta property="og:url" content="http://wjuwju.github.io/2023/10/16/pwn-note/index.html">
<meta property="og:site_name" content="FOR DREAM">
<meta property="og:description" content="pwn-notegcc 编译的指令 NX:-z execstack &#x2F; -z noexecstack (关闭 &#x2F; 开启) Canary:-fno-stack-protector &#x2F;-fstack-protector &#x2F; -fstack-protector-all (关闭 &#x2F; 开启 &#x2F; 全开启) PIE:-no-pie &#x2F; -pi">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://wjuwju-picgo-img.oss-cn-fuzhou.aliyuncs.com/img/QQ%E5%9B%BE%E7%89%8720231017114605.jpg">
<meta property="article:published_time" content="2023-10-15T16:00:00.000Z">
<meta property="article:modified_time" content="2023-10-18T08:48:59.861Z">
<meta property="article:author" content="wjuwju">
<meta property="article:tag" content="note">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://wjuwju-picgo-img.oss-cn-fuzhou.aliyuncs.com/img/QQ%E5%9B%BE%E7%89%8720231017114605.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://wjuwju.github.io/2023/10/16/pwn-note/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'pwn-note(form brokenpoems)',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-10-18 16:48:59'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://wjuwju-picgo-img.oss-cn-fuzhou.aliyuncs.com/img/QQ%E5%9B%BE%E7%89%8720231017114605.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">14</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">8</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://wjuwju-picgo-img.oss-cn-fuzhou.aliyuncs.com/img/1332803.png')"><nav id="nav"><span id="blog-info"><a href="/" title="FOR DREAM"><span class="site-name">FOR DREAM</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">pwn-note(form brokenpoems)</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-10-15T16:00:00.000Z" title="发表于 2023-10-16 00:00:00">2023-10-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-10-18T08:48:59.861Z" title="更新于 2023-10-18 16:48:59">2023-10-18</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PWN/">PWN</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="pwn-note(form brokenpoems)"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="pwn-note"><a href="#pwn-note" class="headerlink" title="pwn-note"></a>pwn-note</h1><h2 id="gcc-编译的指令"><a href="#gcc-编译的指令" class="headerlink" title="gcc 编译的指令"></a>gcc 编译的指令</h2><ul>
<li>NX:<code>-z execstack</code> &#x2F; <code>-z noexecstack</code> (关闭 &#x2F; 开启)</li>
<li>Canary:<code>-fno-stack-protector</code> &#x2F;<code>-fstack-protector</code> &#x2F; <code>-fstack-protector-all</code> (关闭 &#x2F; 开启 &#x2F; 全开启)</li>
<li>PIE:<code>-no-pie</code> &#x2F; <code>-pie</code> (关闭 &#x2F; 开启)</li>
<li>RELRO:<code>-z norelro</code> &#x2F; <code>-z lazy</code> &#x2F; <code>-z now</code> (关闭 &#x2F; 部分开启 &#x2F; 完全开启)</li>
</ul>
<h2 id="plt-got"><a href="#plt-got" class="headerlink" title="plt got"></a>plt got</h2><p><code>plt</code> 是寻址用的-&gt;作用就是去 <code>got</code> 表寻找最后调用 <code>libc</code> 中的函数<br><code>got</code> 可以理解为一个函数指针列表 函数一开始没调用时不是指向libc<br>      指向一段init汇编</p>
<h2 id="recv"><a href="#recv" class="headerlink" title="recv"></a>recv</h2><p>interactive() : 在取得shell之后使用,直接进行交互，相当于回到shell的模式。</p>
<p>recv(numb&#x3D;字节大小, timeout&#x3D;default) : 接收指定字节数。</p>
<p>recvall() : 一直接收直到达到文件EOF。</p>
<p>recvline(keepends&#x3D;True) : 接收一行，keepends为是否保留行尾的\n。</p>
<p>recvuntil(delims, drop&#x3D;False) : 一直读到delims的pattern出现为止。</p>
<p>recvrepeat(timeout&#x3D;default) : 持续接收直到EOF或timeout。</p>
<h2 id="syscall和函数传参"><a href="#syscall和函数传参" class="headerlink" title="syscall和函数传参"></a>syscall和函数传参</h2><p>arm 一般要具体情况具体分析<br>这里列举了常见的4种架构</p>
<ul>
<li>x86<ul>
<li>返回值 : <code>eax</code> </li>
<li>syscall : <code>int 0x80</code></li>
<li>syscall调用号: <code>eax</code></li>
<li>syscall参数: <code>ebx</code>,<code>ecx</code>,<code>edx</code>,<code>esi</code>,<code>edi</code>,<code>ebp</code></li>
<li>函数参数: <code>stack</code></li>
</ul>
</li>
<li>x86_64<ul>
<li>返回值 : <code>rax</code> </li>
<li>syscall : <code>syscall</code></li>
<li>syscall调用号: <code>rax</code></li>
<li>syscall参数: <code>rdi</code>,<code>rsi</code>,<code>rdx</code>,<code>r10</code>,<code>r8</code>,<code>r9</code></li>
<li>函数参数: <code>rdi</code>,<code>rsi</code>,<code>rdx</code>,<code>rcx</code>,<code>r8</code>,<code>r9</code>,<code>stack</code></li>
</ul>
</li>
<li>arm32(aarch32)<ul>
<li>返回值 : <code>r7</code> </li>
<li>syscall : <code>svc 0</code></li>
<li>syscall调用号: <code>r7</code></li>
<li>syscall参数: <code>r0</code>,<code>r1</code>,<code>r2</code>,<code>r3</code>,<code>stack</code></li>
<li>函数参数: <code>r0</code>,<code>r1</code>,<code>r2</code>,<code>r3</code>,<code>stack</code></li>
</ul>
</li>
<li>arm64(aarch64)<ul>
<li>返回值 : <code>x0</code> </li>
<li>syscall : <code>svc 0</code></li>
<li>syscall调用号: <code>x8</code></li>
<li>syscall参数: <code>x0</code>,<code>x1</code>,<code>x2</code>,<code>x3</code>,<code>x4</code>,<code>x5</code></li>
<li>函数参数: <code>x0</code>,<code>x1</code>,<code>x2</code>,<code>x3</code>,<code>x4</code>,<code>x5</code>,<code>x6</code>,<code>x7</code>,<code>stack</code></li>
</ul>
</li>
</ul>
<p>ps: </p>
<ul>
<li>这里注意Linux <code>syscall</code>函数^[<code>int syscall(int syscall_id, ...);</code>使用函数形式传递系统调用号,所以传递到第一个函数参数所对应的存储位置,接下来的几个参数往后推]</li>
<li>x寄存器&#x3D;w寄存器</li>
<li>svc软中断&#x3D;swi软中断</li>
</ul>
<h2 id="gdb-相关-转载自https-www-cnblogs-com-murkuo-p-15965270-html稍有改动"><a href="#gdb-相关-转载自https-www-cnblogs-com-murkuo-p-15965270-html稍有改动" class="headerlink" title="gdb 相关^[转载自https://www.cnblogs.com/murkuo/p/15965270.html稍有改动]"></a>gdb 相关^[转载自<a href="">https://www.cnblogs.com/murkuo/p/15965270.html</a>稍有改动]</h2><h3 id="基本指令"><a href="#基本指令" class="headerlink" title="基本指令"></a>基本指令</h3><ul>
<li><code>help</code> 帮助</li>
<li><code>i</code> info,查看一些信息,只输入 info 可以看可以接什么参数,下面几个比较常用<ul>
<li><code>i b</code> 常用,info break 查看所有断点信息(编号、断点位置)</li>
<li><code>i r</code> 常用,info registers 查看各个寄存器当前的值</li>
<li><code>i f</code> info function 查看所有函数名,需保留符号</li>
</ul>
</li>
<li><code>show</code> 和 info 类似,但是查看调试器的基本信息,如:<ul>
<li><code>show args</code> 查看参数<br><code>rdi</code> 常用,+寄存器名代表一个寄存器内的值,用在地址上直接相当与一个十六进制变量</li>
</ul>
</li>
<li><code>backtrace</code> 查看调用栈</li>
<li><code>q quit</code> 退出,常用</li>
<li><code>vmmap</code> 内存分配情况</li>
</ul>
<h3 id="执行指令"><a href="#执行指令" class="headerlink" title="执行指令"></a>执行指令</h3><ul>
<li><code>s</code> 单步步入,遇到调用跟进函数中,相当于 step into,源码层面的一步<ul>
<li><code>si</code> 常用,同 s,汇编层面的一步</li>
</ul>
</li>
<li><code>n</code> 单步补过,遇到函数不跟进,相当于 step over,源码层面的一步<ul>
<li><code>ni</code> 常用,同 n,汇编层面的一步</li>
</ul>
</li>
<li><code>c continue</code> 常用,继续执行到断点,没断点就一直执行下去</li>
<li><code>r run</code> 常用,重新开始执行</li>
<li><code>start</code> 类似于 run,停在 main 函数的开始</li>
</ul>
<h3 id="断点指令"><a href="#断点指令" class="headerlink" title="断点指令"></a>断点指令</h3><h4 id="下普通断点指令-b-break"><a href="#下普通断点指令-b-break" class="headerlink" title="下普通断点指令 b(break):"></a>下普通断点指令 b(break):</h4><ul>
<li><code>b *(0x123456)</code> 常用,给 0x123456 地址处的指令下断点</li>
<li><code>b *$rebase(0x123456)</code> $rebase 在调试开 PIE 的程序的时候可以直接加上程序的随机地址</li>
<li><code>b func</code> 常用,给函数 func 下断点<ul>
<li><code>b file_name:func_name</code></li>
</ul>
</li>
<li><code>b \*func+47</code> 常用,给地址 func+47 处下断点</li>
<li><code>b file_name:15</code> 给 file_name 的 15 行下断点,要有源码才行<ul>
<li><code>b 15</code></li>
</ul>
</li>
<li><code>b +0x10</code> 在程序当前停住的位置下 0x10 的位置下断点,同样可以-0x10,就是前 0x10</li>
<li><code>break fun if $rdi==5</code> 条件断点,rdi 值为 5 的时候才断</li>
</ul>
<h4 id="删除、禁用断点"><a href="#删除、禁用断点" class="headerlink" title="删除、禁用断点:"></a>删除、禁用断点:</h4><ul>
<li><code>info breakpoints,i b</code> 查看断点编号</li>
<li><code>delete 5,d 5</code>常用,删除 5 号断点,直接 delete 不接数字删除所有</li>
<li><code>disable 5</code> 常用,禁用 5 号断点</li>
<li><code>enable 5</code> 启用 5 号断点</li>
<li><code>clear</code> 清除下面的所有断点</li>
</ul>
<h4 id="内存断点指令-watch"><a href="#内存断点指令-watch" class="headerlink" title="内存断点指令 watch:"></a>内存断点指令 watch:</h4><ul>
<li><code>watch 0x123456</code> 0x123456 地址的数据改变的时候会断</li>
<li><code>watch a</code> 变量 a 改变的时候会断</li>
<li><code>info watchpoints</code> 查看 watch 断点信息</li>
</ul>
<h4 id="捕获断点-catch"><a href="#捕获断点-catch" class="headerlink" title="捕获断点 catch:"></a>捕获断点 catch:</h4><ul>
<li><code>catch syscall</code> syscall 系统调用的时候断住</li>
<li><code>tcatch syscall </code>syscall 系统调用的时候断住,只断一次</li>
<li><code>info breakpoints</code> catch 的断点可以通过 i b 查看<br>除 <code>syscall</code> 外还可以使用的有:<ol>
<li><code>throw</code>: 抛出异常</li>
<li><code>catch</code>: 捕获异常</li>
<li><code>exec</code>: exec 被调用</li>
<li><code>fork</code>: fork 被调用</li>
<li><code>vfork</code>: vfork 被调用</li>
<li><code>load</code>: 加载动态库</li>
<li><code>load libname</code>: 加载名为 libname 的动态库</li>
<li><code>unload</code>: 卸载动态库</li>
<li><code>unload libname</code>: 卸载名为 libname 的动态库</li>
<li><code>syscall [args]</code>: 调用系统调用,args 可以指定系统调用号,或者系统名称</li>
</ol>
</li>
</ul>
<h3 id="打印指令"><a href="#打印指令" class="headerlink" title="打印指令"></a>打印指令</h3><h4 id="查看内存指令-x"><a href="#查看内存指令-x" class="headerlink" title="查看内存指令 x:"></a>查看内存指令 x:</h4><ul>
<li><code>x /nuf 0x123456</code> 常用,x 指令的格式是:x 空格&#x2F;nfu,nfu 代表三个参数<ul>
<li><code>n</code> 代表显示几个单元(而不是显示几个字节,后面的 u 表示一个单元多少个字节),放在&#x2F;后面</li>
<li><code>u</code> 代表一个单元几个字节,b(一个字节),h(2 字节),w(四字节),g(八字节)</li>
<li><code>f</code> 代表显示数据的格式,f 和 u 的顺序可以互换,也可以只有一个或者不带 n,用的时候很灵活<ol>
<li>x 按十六进制格式显示变量。</li>
<li>d 按十进制格式显示变量。</li>
<li>u 按十六进制格式显示无符号整型。</li>
<li>o 按八进制格式显示变量。</li>
<li>t 按二进制格式显示变量。</li>
<li>a 按十六进制格式显示变量。</li>
<li>c 按字符格式显示变量。</li>
<li>f 按浮点数格式显示变量。</li>
<li>s 按字符串显示。</li>
<li>b 按字符显示。</li>
<li>i 显示汇编指令。</li>
</ol>
</li>
</ul>
</li>
<li><code>x /10gx 0x123456</code> 常用,从 0x123456 开始每个单元八个字节,十六进制显示 10 个单元的数据</li>
<li><code>x /10xd $rdi</code> 从 rdi 指向的地址向后打印 10 个单元,每个单元 4 字节的十进制数</li>
<li><code>x /10i 0x123456</code> 常用,从 0x123456 处向后显示十条汇编指令</li>
</ul>
<h4 id="打印指令-p-print"><a href="#打印指令-p-print" class="headerlink" title="打印指令 p(print):"></a>打印指令 p(print):</h4><ul>
<li><code>p func</code> 打印函数 func 的地址,需要保留符号</li>
<li><code>p 0x10-0x08</code> 计算 0x10-0x08 的结果</li>
<li><code>p &amp;a</code> 查看变量 a 的地址</li>
<li><code>p *(0x123456)</code> 查看 0x123456 地址的值,注意和 x 指令的区别,x 指令查看地址的值不用星号</li>
<li><code>p $rdi</code> 显示 rdi 寄存器的值,注意和 x 的区别,这只是显示 rdi 的值,而不是 rdi 指向的值</li>
<li><code>p *$rdi</code> 显示 rdi 指向的值</li>
</ul>
<h4 id="打印汇编指令-disass-disassemble"><a href="#打印汇编指令-disass-disassemble" class="headerlink" title="打印汇编指令 disass(disassemble):"></a>打印汇编指令 disass(disassemble):</h4><ul>
<li><code>disass 0x123456</code> 显示 0x123456 前后的汇编指令</li>
<li><code>x /10i</code> 也可以使用 x 指令</li>
</ul>
<h4 id="打印源代码指令-list"><a href="#打印源代码指令-list" class="headerlink" title="打印源代码指令 list:"></a>打印源代码指令 list:</h4><ul>
<li><code>list</code> 查看当前附近 10 行代码,要有源码,list 指令 pwn 题中几乎不用,但为了完整性还是简单举几个例子</li>
<li><code>list 38</code> 查看 38 行附近 10 行代码</li>
<li><code>list 1,10</code> 查看 1-10 行</li>
<li><code>list main</code> 查看 main 函数开始 10 行</li>
</ul>
<h3 id="修改和查找指令"><a href="#修改和查找指令" class="headerlink" title="修改和查找指令"></a>修改和查找指令</h3><h4 id="修改数据指令-set"><a href="#修改数据指令-set" class="headerlink" title="修改数据指令 set:"></a>修改数据指令 set:</h4><ul>
<li><code>set $rdi=0x10</code> 把 rdi 寄存器的值变为 0x10</li>
<li><code>set *0x123456=0x10</code> 0x123456 地址的值变为 0x10,注意带星号</li>
<li><code>set args &quot;abc&quot; &quot;def&quot; &quot;gh&quot;</code> 给参数 123 赋值</li>
<li><code>set args &quot;python -c &#39;printf(&quot;1234\x7f\xde&quot;)&#39;&quot;</code> 使用 python 给参数赋值不可见字符</li>
</ul>
<h4 id="查找数据"><a href="#查找数据" class="headerlink" title="查找数据:"></a>查找数据:</h4><ul>
<li><code>search rdi</code> 从当前位置向后查包含 rdi 的指令,返回若干</li>
<li><code>search -h</code> 查看 search 帮助,我也不太长用这个指令</li>
<li><code>find &quot;hello&quot;</code> 查找 hello 字符串,pwndbg 独有</li>
<li><code>ropgadget</code> 查找 ropgadget,pwndbg 独有,没啥用,可以用其他工具</li>
</ul>
<h3 id="堆操作指令-pwndbg-插件独有"><a href="#堆操作指令-pwndbg-插件独有" class="headerlink" title="堆操作指令(pwndbg 插件独有)&#96;"></a>堆操作指令(pwndbg 插件独有)&#96;</h3><ul>
<li><code>arena</code> 显示 arena 的详细信息</li>
<li><code>arenas</code> 显示所有 arena 的基本信息</li>
<li><code>arenainfo</code> 好看的显示所有 arena 的信息</li>
<li><code>bins</code> 常用,查看所有种类的堆块的链表情况</li>
<li><code>fastbins</code> 单独查看 fastbins 的链表情况</li>
<li><code>largebins</code> 同上,单独查看 largebins 的链表情况</li>
<li><code>smallbins</code> 同上,单独查看 smallbins 的链表情况</li>
<li><code>unsortedbin</code> 同上,单独查看 unsortedbin 链表情况</li>
<li><code>tcachebins</code> 同上,单独查看 tcachebins 的链表情况</li>
<li><code>tcache</code> 查看 tcache 详细信息</li>
<li><code>heap</code> 数据结构的形式显示所有堆块,会显示一大堆</li>
<li><code>heapbase</code> 查看堆起始地址</li>
<li><code>heapinfo heapinfoall</code> 显示堆得信息,和 bins 的挺像的,没 bins 好用</li>
<li><code>parseheap</code> 显示堆结构,很好用</li>
<li><code>tracemalloc</code> 好用,会跟提示所有操作堆的地方</li>
</ul>
<h3 id="其他-pwndbg-插件独有指令"><a href="#其他-pwndbg-插件独有指令" class="headerlink" title="其他 pwndbg 插件独有指令"></a>其他 pwndbg 插件独有指令</h3><ul>
<li><code>cyclic(cyc)</code> 生成用来溢出的字符串,如<ul>
<li><code>cyc -l aaaa/0x6161616161616161</code> 返回溢出的 aaaa 溢出前有多少个字符</li>
<li><code>cyc 50</code> 生成一个 50 长度的溢出字符串(根据不同平台不同)</li>
</ul>
</li>
<li><code>$rebase</code> 开启 PIE 的情况的地址偏移<ul>
<li><code>b *$rebase(0x123456)</code> 断住 PIE 状态下的二进制文件中 0x123456 的地方</li>
<li><code>codebase</code> 打印 PIE 偏移,与 rebase 不同,这是打印,rebase 是使用</li>
</ul>
</li>
<li><code>stack</code> 查看栈</li>
<li><code>retaddr</code> 打印包含返回地址的栈地址</li>
<li><code>canary</code> 直接看 canary 的值</li>
<li><code>plt</code> 查看 plt 表</li>
<li><code>got</code> 查看 got 表</li>
<li><code>hexdump</code> 像 IDA 那样显示数据,带字符串</li>
</ul>
<h2 id="libc版本对应"><a href="#libc版本对应" class="headerlink" title="libc版本对应"></a>libc版本对应</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Ubuntu22.04: libc-2.35</span><br><span class="line"></span><br><span class="line">Ubuntu20.04: libc-2.31</span><br><span class="line">Ubuntu18.04: linc-2.27</span><br><span class="line"></span><br><span class="line">Ubuntu16.04: libc-2.23</span><br><span class="line">Ubuntu14.04: libc-2.19</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://elixir.bootlin.com/glibc/glibc-2.30/source%60libc%E6%BA%90%E7%A0%81%60">https://elixir.bootlin.com/glibc/glibc-2.30/source`libc源码`</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="http://wjuwju.github.io">wjuwju</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="http://wjuwju.github.io/2023/10/16/pwn-note/">http://wjuwju.github.io/2023/10/16/pwn-note/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://wjuwju.github.io" target="_blank">FOR DREAM</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/note/">note</a></div><div class="post_share"><div class="social-share" data-image="https://wjuwju-picgo-img.oss-cn-fuzhou.aliyuncs.com/img/QQ%E5%9B%BE%E7%89%8720231017114605.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/2023/10/16/%5BSWPUCTF%202021%20%E6%96%B0%E7%94%9F%E8%B5%9B%5Dwhitegive_pwn/" title="SWPUCTF 2021 新生赛_whitegive_pwn"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">SWPUCTF 2021 新生赛_whitegive_pwn</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://wjuwju-picgo-img.oss-cn-fuzhou.aliyuncs.com/img/QQ%E5%9B%BE%E7%89%8720231017114605.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">wjuwju</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">14</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">8</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/wjuwju"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/wjuwju" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:wjuwju233@qq.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Thank you for reading.</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#pwn-note"><span class="toc-number">1.</span> <span class="toc-text">pwn-note</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#gcc-%E7%BC%96%E8%AF%91%E7%9A%84%E6%8C%87%E4%BB%A4"><span class="toc-number">1.1.</span> <span class="toc-text">gcc 编译的指令</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#plt-got"><span class="toc-number">1.2.</span> <span class="toc-text">plt got</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#recv"><span class="toc-number">1.3.</span> <span class="toc-text">recv</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#syscall%E5%92%8C%E5%87%BD%E6%95%B0%E4%BC%A0%E5%8F%82"><span class="toc-number">1.4.</span> <span class="toc-text">syscall和函数传参</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#gdb-%E7%9B%B8%E5%85%B3-%E8%BD%AC%E8%BD%BD%E8%87%AAhttps-www-cnblogs-com-murkuo-p-15965270-html%E7%A8%8D%E6%9C%89%E6%94%B9%E5%8A%A8"><span class="toc-number">1.5.</span> <span class="toc-text">gdb 相关^[转载自https:&#x2F;&#x2F;www.cnblogs.com&#x2F;murkuo&#x2F;p&#x2F;15965270.html稍有改动]</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%8C%87%E4%BB%A4"><span class="toc-number">1.5.1.</span> <span class="toc-text">基本指令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%89%A7%E8%A1%8C%E6%8C%87%E4%BB%A4"><span class="toc-number">1.5.2.</span> <span class="toc-text">执行指令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%AD%E7%82%B9%E6%8C%87%E4%BB%A4"><span class="toc-number">1.5.3.</span> <span class="toc-text">断点指令</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%B8%8B%E6%99%AE%E9%80%9A%E6%96%AD%E7%82%B9%E6%8C%87%E4%BB%A4-b-break"><span class="toc-number">1.5.3.1.</span> <span class="toc-text">下普通断点指令 b(break):</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E3%80%81%E7%A6%81%E7%94%A8%E6%96%AD%E7%82%B9"><span class="toc-number">1.5.3.2.</span> <span class="toc-text">删除、禁用断点:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%86%85%E5%AD%98%E6%96%AD%E7%82%B9%E6%8C%87%E4%BB%A4-watch"><span class="toc-number">1.5.3.3.</span> <span class="toc-text">内存断点指令 watch:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8D%95%E8%8E%B7%E6%96%AD%E7%82%B9-catch"><span class="toc-number">1.5.3.4.</span> <span class="toc-text">捕获断点 catch:</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%89%93%E5%8D%B0%E6%8C%87%E4%BB%A4"><span class="toc-number">1.5.4.</span> <span class="toc-text">打印指令</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%86%85%E5%AD%98%E6%8C%87%E4%BB%A4-x"><span class="toc-number">1.5.4.1.</span> <span class="toc-text">查看内存指令 x:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%89%93%E5%8D%B0%E6%8C%87%E4%BB%A4-p-print"><span class="toc-number">1.5.4.2.</span> <span class="toc-text">打印指令 p(print):</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%89%93%E5%8D%B0%E6%B1%87%E7%BC%96%E6%8C%87%E4%BB%A4-disass-disassemble"><span class="toc-number">1.5.4.3.</span> <span class="toc-text">打印汇编指令 disass(disassemble):</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%89%93%E5%8D%B0%E6%BA%90%E4%BB%A3%E7%A0%81%E6%8C%87%E4%BB%A4-list"><span class="toc-number">1.5.4.4.</span> <span class="toc-text">打印源代码指令 list:</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E5%92%8C%E6%9F%A5%E6%89%BE%E6%8C%87%E4%BB%A4"><span class="toc-number">1.5.5.</span> <span class="toc-text">修改和查找指令</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E6%95%B0%E6%8D%AE%E6%8C%87%E4%BB%A4-set"><span class="toc-number">1.5.5.1.</span> <span class="toc-text">修改数据指令 set:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9F%A5%E6%89%BE%E6%95%B0%E6%8D%AE"><span class="toc-number">1.5.5.2.</span> <span class="toc-text">查找数据:</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%A0%86%E6%93%8D%E4%BD%9C%E6%8C%87%E4%BB%A4-pwndbg-%E6%8F%92%E4%BB%B6%E7%8B%AC%E6%9C%89"><span class="toc-number">1.5.6.</span> <span class="toc-text">堆操作指令(pwndbg 插件独有)&#96;</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B6%E4%BB%96-pwndbg-%E6%8F%92%E4%BB%B6%E7%8B%AC%E6%9C%89%E6%8C%87%E4%BB%A4"><span class="toc-number">1.5.7.</span> <span class="toc-text">其他 pwndbg 插件独有指令</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#libc%E7%89%88%E6%9C%AC%E5%AF%B9%E5%BA%94"><span class="toc-number">1.6.</span> <span class="toc-text">libc版本对应</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/11/01/HackerGame%20WP/" title="无题">无题</a><time datetime="2023-11-01T07:14:11.290Z" title="发表于 2023-11-01 15:14:11">2023-11-01</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/10/27/%5BNISACTF%202022%5DReorPwn/" title="NISACTF 2022-ReorPwn?">NISACTF 2022-ReorPwn?</a><time datetime="2023-10-26T16:00:00.000Z" title="发表于 2023-10-27 00:00:00">2023-10-27</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/10/27/%5BNISACTF%202022%5Dezpie/" title="NISACTF 2022-ezpie">NISACTF 2022-ezpie</a><time datetime="2023-10-26T16:00:00.000Z" title="发表于 2023-10-27 00:00:00">2023-10-27</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/10/24/%5BISCTF2022%5Deasy_ret2libc/" title="ISCTF2022 easy_ret2libc">ISCTF2022 easy_ret2libc</a><time datetime="2023-10-23T16:00:00.000Z" title="发表于 2023-10-24 00:00:00">2023-10-24</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/10/23/FSCTF%E6%96%B0%E7%94%9F%E8%B5%9Bnc/" title="FSCTF新生赛nc">FSCTF新生赛nc</a><time datetime="2023-10-22T16:00:00.000Z" title="发表于 2023-10-23 00:00:00">2023-10-23</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By wjuwju</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-fluttering-ribbon.min.js"></script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-show-text.min.js" data-mobile="true" data-text="+1s" data-fontsize="15px" data-random="false" async="async"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>